//
//  SetViewController.m
//  Pacific_Computer
//
//  Created by dlios on 14-12-25.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SetViewController.h"
#import "UIColor+AddColor.h"
#import "SDImageCache.h"
#import "AppDelegate.h"
#import "WeiboSDK.h"
#import "WBHttpRequest.h"

@interface SetViewController () <WBHttpRequestDelegate>




@end

@implementation SetViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver:self selector:@selector(receiveNotifica:) name:@"kuaipao" object:nil];
        
    }
    return self;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (void)receiveNotifica:(NSNotificationCenter *)center
{
    self.swButton = YES;
    NSLog(@"收到消息");
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor huiseColor];
    
    
    UIButton * quitButton = [UIButton buttonWithType:UIButtonTypeSystem];
    quitButton.frame = CGRectMake(self.view.bounds.size.width * 13.33 /100, self.view.bounds.size.height *81 / 100, self.view.bounds.size.width * 73.33 / 100, self.view.bounds.size.height * 6.5 /100);
    quitButton.backgroundColor = [UIColor hongse];
    quitButton.titleLabel.font = [UIFont systemFontOfSize:19];
    [quitButton setTitle:@"注销" forState:UIControlStateNormal];
    quitButton.tintColor = [UIColor whiteColor];
    [quitButton addTarget:self action:@selector(buttonClicked2:) forControlEvents:UIControlEventTouchUpInside];
    quitButton.layer.cornerRadius = 20;
    [self.view addSubview:quitButton];
    
    
    UIButton *deleButton = [UIButton buttonWithType:UIButtonTypeSystem];
    deleButton.frame = CGRectMake(self.view.bounds.size.width * 13.33 /100, self.view.bounds.size.height * 70.3 / 100, self.view.bounds.size.width * 73.33 / 100, self.view.bounds.size.height * 6.5 /100);
    deleButton.titleLabel.font = [UIFont systemFontOfSize:18];
    deleButton.layer.cornerRadius = 20;
    deleButton.tintColor = [UIColor whiteColor];
    deleButton.backgroundColor = [UIColor hongse];
    [deleButton setTitle:@"清空缓存" forState:UIControlStateNormal];
    [deleButton addTarget:self action:@selector(buttonClicked1:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:deleButton];
    
    
    
    
    
    
    
}
- (WBMessageObject *)messageToShare
{
    
    
    WBMessageObject *message = [WBMessageObject message];
        message.text = @"bbbbb";
    WBImageObject *image = [WBImageObject object];
    image.imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"meijing3" ofType:@"png"]];
    message.imageObject = image;

    
    
    
    return message;
}


- (void)buttonClicked2:(UIButton *)button
{
    AppDelegate *myDelegate =(AppDelegate*)[[UIApplication sharedApplication] delegate];
    [WeiboSDK logOutWithToken:myDelegate.wbtoken delegate:self withTag:@"111"];
    if (self.swButton == YES) {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"注销成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
            [alert show];
            [alert release];
            self.swButton = NO;
        });
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"tamenpaole" object:@"香皂" userInfo: dic];

    }
    

}


- (void)buttonClicked1:(UIButton *)button
{
    float num = [[SDImageCache sharedImageCache] checkTmpSize];
    [[SDImageCache sharedImageCache] clearDisk];
    NSString * str = [NSString stringWithFormat:@"缓存清除成功, 大小为%.2fMB",num];
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
    [alertView show];
    [alertView release];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
